﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.ComponentModel;


namespace ContactCRUD.Classes
{


    /// <summary>
    /// This class is the base class for all ViewModel classes.
    /// </summary>
    public class BaseObject : INotifyPropertyChanged
    {
        public BaseObject()
        {
            IsDirty = false;
        }

        
        public bool IsDirty { get; set; }

        #region Public error properties
        public bool IsValid { get; set; }
        
        #endregion

        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;

        /// <summary>
        /// Functie de validare
        /// </summary>
        /// <param name="propertyNames">Lista de sirurl de caractere care sunt modificate.</param>
        protected virtual void NotifyChanged(params string[] propertyNames)
        {
            // update the dirty flag for this class
            IsDirty = true;
            foreach (string name in propertyNames)
            {
                RaisePropertyChanged(name);
            }
        }

        /// <summary>
        /// Helper method to raise the PropertyChanged event.
        /// </summary>
        /// <param name="PropertyName">The name of the property that has been changed, as a string.</param>
        protected void RaisePropertyChanged(string PropertyName)
        {
             
            if (this.PropertyChanged != null)
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs(PropertyName));
            }
        }

        #endregion 

        
         
    }
}
